package org.jet.emall.prod.transfer;

import org.jet.emall.prod.dto.NewSpuDTO;
import org.jet.emall.prod.dto.SpuImageDTO;
import org.jet.emall.prod.dto.SpuViewDTO;
import org.jet.emall.prod.po.ProdSpu;
import org.jet.emall.prod.po.ProdSpuImage;
import org.jet.emall.prod.po.SpuView;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author xiaozai
 * @version 1.0
 * @date 2020-04-15 12:02
 */
@Mapper
public interface SpuDtoTransfer {

    SpuDtoTransfer INSTANCE = Mappers.getMapper(SpuDtoTransfer.class);


    /**
     *  将SPU PO列表 转DTO列表
     * @param records
     * @return
     */
    List<SpuViewDTO> toDtoList(List<SpuView> records);

    /**
     *  将SPU PO 转DTO
     * @param one
     * @return
     */
    SpuViewDTO toDto(SpuView one);

    /**
     *  将新建SPU模型DTO 转 PO
     * @param newSpuDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "id",ignore = true)
    })
    ProdSpu toPo(NewSpuDTO newSpuDTO);

    /**
     *  将SPU图片PO列表转DTO列表
     * @param list
     * @return
     */
    List<SpuImageDTO> toImageDtoList(List<ProdSpuImage> list);

    /**
     *  将SPU图片DTO转PO
     * @param dto
     * @return
     */
    ProdSpuImage toImagePo(SpuImageDTO dto);
}
